@echo off
echo 创建初始化脚本...
echo "use gof23-game;" > mongo-init-temp.js
echo "db.users.drop();" >> mongo-init-temp.js
echo "db.progress.drop();" >> mongo-init-temp.js
echo "db.patterns.drop();" >> mongo-init-temp.js
echo "db.challenges.drop();" >> mongo-init-temp.js

echo "db.users.insertOne({" >> mongo-init-temp.js
echo "  name: '测试用户'," >> mongo-init-temp.js
echo "  email: 'test@example.com'," >> mongo-init-temp.js
echo "  password: '$2a$10$XQDpG7aKOKrOKh5OjQZkiO7UMcKIJDqDFsQqJ6nFf2ZTINrxMEE6G'," >> mongo-init-temp.js
echo "  date: new Date()," >> mongo-init-temp.js
echo "  _id: ObjectId('5d7a514b5d2c12c7449be042')" >> mongo-init-temp.js
echo "});" >> mongo-init-temp.js

echo "print('数据库初始化完成!');" >> mongo-init-temp.js

echo 将初始化脚本复制到MongoDB容器...
docker cp mongo-init-temp.js gof23-mongodb:/tmp/mongo-init-temp.js

echo 在MongoDB容器中执行初始化脚本...
docker exec gof23-mongodb mongosh --file /tmp/mongo-init-temp.js

echo 清理临时文件...
del mongo-init-temp.js

echo.
pause 